package com.yzt.dynamicmodule.viewpagerlayoutmanager;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.viewpager.widget.ViewPager;
import androidx.viewpager2.widget.ViewPager2;

/**
 * 作者：bobwang
 * 创建时间：2024-01-28 23:37:47
 * 描述：
 */
public class CustomViewPager extends ViewPager {
    private boolean scrollable;

    public CustomViewPager(Context context) {
        super(context);
        scrollable = true;
    }

    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
        scrollable = true;
    }

    public void setScrollable(boolean scrollable) {
        this.scrollable = scrollable;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return scrollable && super.onTouchEvent(event);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return scrollable && super.onInterceptTouchEvent(event);
    }
}